package com.ag.lwc.dao;

import java.util.List;

import org.hibernate.Session;
import org.hibernate.Transaction;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.ag.bean.TbSwitch;

public class SwitchDAO extends HibernateDaoSupport
{
	public  TbSwitch find()
	{
		Session session = this.getSessionFactory().openSession();
		TbSwitch myswitch = null;
		List<TbSwitch> switchs = session.createQuery("from TbSwitch").list();
		if(switchs.size()>0)
			myswitch = switchs.get(0);
		session.close();
		return myswitch;
	}
	
	
	public void update(TbSwitch myswitch)
	{
		Session session = this.getSessionFactory().openSession();
		Transaction tx = session.beginTransaction();
		session.saveOrUpdate(myswitch);
		tx.commit();
		session.close();
	}
	
	

}
